<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript" src="<s:url value="/js/protocollist.js"/>"></script>

<style type="text/css">
    #main
    {
        width: 80%;
        margin-top: 0px;
        background-color: #FFFFFF;
    }
</style>


<div id="filter">
    <s:form action="list" cssClass="tableFilter">
        <tr>
            <th colspan="4" class="tableTitle">
                <h5>Search</h5>
            </th>
        </tr>

        <tr>
            <td>
                <label>Protocol ID:</label>
            </td>
            <td>
                <s:textfield label="Protocol ID" name="protocol.id" theme="simple"/>
            </td>
        </tr>
        <tr>
            <td>
                <label>Drug Name:</label>
            </td>
            <td>
                <s:textfield label="Drug Name" name="protocol.drogas[0].drugName"  theme="simple" />
            </td>
        </tr>
        <tr>
            <td>
                <label>Drug Number:</label>
            </td>
            <td>
                <s:textfield label="Drug Number" name="protocol.drogas[0].drugNumber" theme="simple" />
            </td>
        </tr>
        <tr>
            <td>
                <label>Therapeutic Area:</label>
            </td>
            <td>
                <s:select label=""   name="protocol.therapeuticArea.id"       value="%{protocol.therapeuticArea.id}"
                          headerKey="" headerValue="Choose an Area"
                          list="therapeuticAreas"
                          listKey="id"
                          listValue="name"
                          theme="simple">
                </s:select>
            </td>
        </tr>
        <tr>
            <td>
                <label>Specialty:</label>
            </td>
            <td>
                <s:select label="Drug"   name="protocol.speciality.id"
                          headerKey="" headerValue="Choose a Specialty"
                          list="specialtyList"
                          listKey="id"
                          listValue="name"
                          theme="simple">
                </s:select>
            </td>
        </tr>

        <tr>
            <td colspan="4" class="centeredButtons"><s:submit value="Search" name="filter" theme="simple" />
                <s:submit action="create" value="New" theme="simple"/></td>

        </tr>

    </s:form>
</div>

<s:if test="!list.isEmpty()">
    <div id="table_content">
        <table>
            <thead>
            <tr>
                <th>Protocol ID</th>
                <th>Drug Name</th>
                <th>Therapeutic Area</th>
                <th>Specialty</th>
                <th>Country</th>
            </tr>
            </thead>
            <tbody>
            <s:iterator value="list">
            <tr>
                <th><s:property value="id"/></th>
                <th><s:iterator value="drogas" status="statDrug" >
                    <s:property value="drugName" />
                    <s:if test="#statDrug.last == false">,</s:if>
                </s:iterator>
                </th>
                <th><s:property value="therapeuticArea.name"/></th>
                <th><s:property value="speciality.name"/></th>
                <th><s:iterator value="protocoloCompromisopaises" status="statPais" >
                    <s:property value="compromisopais.country" />
                    <s:if test="#statPais.last == false">,</s:if>
                </s:iterator>
                </th>

                <th>
                    <s:form action="select" method="POST" theme="simple">
                        <s:hidden id="compromisopaisId" name="compromisopaisId"/>
                        <s:hidden value="%{id}" name="editableProtocoloId"/>
                        <s:submit value="Select" name="select" />
                    </s:form>
                </th>
            </tr>
            </s:iterator>
            <tbody>
        </table>
    </div>
</s:if>
<script type="text/javascript">
    var list = true;
    $('#search').css({"color":"#EE5102","fontWeight":"bold"});
</script>